var FlashMouseController = {
	
	FlashID: "FlashID",
	ContainerID: "FlashContentDiv",
	
	init: function () {
		if (window.addEventListener) {
			document.oncontextmenu = this.killEvents;
			window.addEventListener("mousedown", this.onOtherMouse, true);
		} else {
			document.oncontextmenu = function () {
				if (window.event.srcElement.id == FlashMouseController.FlashID) {
					return false;
				}
			};
			document.getElementById(this.ContainerID).onmouseup = function () {
				document.getElementById(FlashMouseController.ContainerID).releaseCapture();
			};
			document.getElementById(this.ContainerID).onmousedown = this.onIEMouse;
		}
	},
	
	killEvents: function (e) {
		var evt = e;
		if (evt == null || typeof (evt) == "undefined") {
		    evt = event;
		}
		var target = evt.srcElement ? evt.srcElement : evt.target;
		if (target.id == FlashMouseController.FlashID) {
			if (evt.stopPropagation) evt.stopPropagation();
			if (evt.preventDefault)  evt.preventDefault();
			if (evt.preventCapture)  evt.preventCapture();
			if (evt.preventBubble)   evt.preventBubble();
		}
	},
	
	onOtherMouse: function (e) {
		if (e.button != 0) {
			FlashMouseController.killEvents(e);
			if (e.target.id == FlashMouseController.FlashID) {
				FlashMouseController.callback();
			}
		}
	},
	
	onIEMouse: function (e) {
		if (event.button > 1) {
			if (window.event.srcElement.id == FlashMouseController.FlashID) {
				FlashMouseController.callback();
			}
			document.getElementById(FlashMouseController.ContainerID).setCapture();
		}
	},
	
	callback: function () {
		if(document.getElementById(this.FlashID).onFlashRightClick) {
			document.getElementById(this.FlashID).onFlashRightClick();
		}
	}
	
}